import axios from './utils/myAxios'

interface UserInfo {

}

interface UserResource {

}
class SsoService {
    readonly jwtStorageKey: string
    jwt: string|undefined;
    constructor() {
        this.jwtStorageKey = "JWT"        
    }

    async getJwtByToken(token: String): Promise<String> {
        let path = `/sso?token=${token}`
        let rsp = await axios.post(path)
        debugger
        let jwt = rsp.data as String
        debugger
        window.localStorage[this.jwtStorageKey] = jwt
        return jwt
    }

    async getUserMenu(): Promise<UserResource[]> {
        let path = `/sso/user_menu`
        let rsp = await axios.get(path)
        return rsp.data as UserResource[]
    }
}

export let ssoService = new SsoService()